package com.hikeen.launcherx.floatwindow;

import android.app.Service;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

import androidx.annotation.Nullable;

/**
 * Author by LY
 * Email 1078410438@qq.com
 * Date on 2022/3/5.
 */
public class MainService extends Service {
    private static String TAG = "MAINSERVICE";
    public MyBinder myBinder = new MyBinder();

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return myBinder;
    }


    @Override
    public void onCreate() {
        Log.d(TAG, "onCreate: ");
        super.onCreate();
        LRWindowManagers.getInstance().init(getApplicationContext());
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        return super.onStartCommand(intent, flags, startId);
    }

    public void onBoom(){
        LRWindowManagers.getInstance().onBoom();
    }

    public class MyBinder extends Binder {

        public MainService getService() {
            return MainService.this;
        }
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        LRWindowManagers.getInstance().onBoom();
        LRWindowManagers.getInstance().init(getApplicationContext());
    }
}
